package com.base.www.EnumLearn;

/**
 * Created by wangyang on 2017/7/31.
 */
public enum Operation {
    PLUS("+"){
        double apply(double x, double y){
            return x + y;
        }
    },
    MINUS("-"){
        double apply(double x, double y){
            return x - y;
        }
    },
    TIMES("*"){
        double apply(double x, double y){
            return x * y;
        }
    },
    DIVIDS("/"){
        double apply(double x, double y){
            return x / y;
        }
    };
    private final String symbol;
    Operation(String symbol){this.symbol=symbol;}
    @Override public String toString(){return symbol;}
    abstract double apply(double x, double y);

    public static void main(String[] args){
        System.out.println(Operation.PLUS.apply(1,2));
        System.out.println(Operation.MINUS.apply(1,2));
        System.out.println(Operation.TIMES.apply(1,2));
        System.out.println(Operation.DIVIDS.apply(1,2));
    }
}
